<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noodp" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
        <title>09-面向对象编程语言 - Adbean&#39;s Blog</title><meta name="Description" content="Adbean&#39;s Blog"><meta property="og:title" content="09-面向对象编程语言" />
<meta property="og:description" content="类和对象 根据后面的素材，识别类和对象。 阅读“牧师与恶魔过河”的游戏介绍并玩游 戏。然后回答问题 游戏涉及哪些类。请列表说明 游戏中有哪些对象，各几" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://adbean.gitee.io/posts/my-ninth-post/" />
<meta property="og:image" content="https://adbean.gitee.io/logo.png"/>
<meta property="article:published_time" content="2020-10-24T19:57:39+08:00" />
<meta property="article:modified_time" content="2020-10-24T19:57:39+08:00" />
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="https://adbean.gitee.io/logo.png"/>

<meta name="twitter:title" content="09-面向对象编程语言"/>
<meta name="twitter:description" content="类和对象 根据后面的素材，识别类和对象。 阅读“牧师与恶魔过河”的游戏介绍并玩游 戏。然后回答问题 游戏涉及哪些类。请列表说明 游戏中有哪些对象，各几"/>
<meta name="application-name" content="Adbean&#39;s Blog">
<meta name="apple-mobile-web-app-title" content="Adbean&#39;s Blog"><meta name="theme-color" content="#ffffff"><meta name="msapplication-TileColor" content="#da532c"><link rel="icon" href="../../Owl.ico"><link rel="apple-touch-icon" sizes="180x180" href="../../apple-touch-icon.png"><link rel="mask-icon" href="../../safari-pinned-tab.svg" color="#5bbad5"><link rel="manifest" href="../../site.webmanifest"><link rel="canonical" href="https://adbean.gitee.io/posts/my-ninth-post/" /><link rel="prev" href="https://adbean.gitee.io/posts/my-fourth-project/" /><link rel="next" href="https://adbean.gitee.io/posts/my-tenth-post/" /><link rel="stylesheet" href="../../lib/normalize/normalize.min.css"><link rel="stylesheet" href="../../css/style.min.css"><link rel="stylesheet" href="../../lib/fontawesome-free/all.min.css"><link rel="stylesheet" href="../../lib/animate/animate.min.css"><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "09-面向对象编程语言",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https:\/\/adbean.gitee.io\/posts\/my-ninth-post\/"
        },"genre": "posts","keywords": "作业, 面向对象","wordcount":  528 ,
        "url": "https:\/\/adbean.gitee.io\/posts\/my-ninth-post\/","datePublished": "2020-10-24T19:57:39+08:00","dateModified": "2020-10-24T19:57:39+08:00","publisher": {
            "@type": "Organization",
            "name": "Adbean"},"author": {
                "@type": "Person",
                "name": "Adbean"
            },"description": ""
    }
    </script></head>
    <body header-desktop="fixed" header-mobile="auto"><script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('dark' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : 'dark' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>

        <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="../../" title="Adbean&#39;s Blog"><img
        class="lazyload logo"
        src="../../svg/loading.min.svg"
        data-src="../../Owl.ico"
        data-srcset="../../Owl.ico, ../../Owl.ico 1.5x, ../../Owl.ico 2x"
        data-sizes="auto"
        alt="/Owl.ico"
        title="/Owl.ico" />Adbean&#39;s Blog</a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="../../"> 主页 </a><a class="menu-item" href="../../posts/"> 文章 </a><a class="menu-item" href="../../posts/my-index/"> 索引 </a><a class="menu-item" href="../../tags/"> 标签 </a><a class="menu-item" href="../../categories/"> 分类 </a><span class="menu-item delimiter"></span><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                    <i class="fas fa-adjust fa-fw"></i>
                </a>
            </div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="../../" title="Adbean&#39;s Blog"><img
        class="lazyload logo"
        src="../../svg/loading.min.svg"
        data-src="../../Owl.ico"
        data-srcset="../../Owl.ico, ../../Owl.ico 1.5x, ../../Owl.ico 2x"
        data-sizes="auto"
        alt="/Owl.ico"
        title="/Owl.ico" />Adbean&#39;s Blog</a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><a class="menu-item" href="../../" title="">主页</a><a class="menu-item" href="../../posts/" title="">文章</a><a class="menu-item" href="../../posts/my-index/" title="">索引</a><a class="menu-item" href="../../tags/" title="">标签</a><a class="menu-item" href="../../categories/" title="">分类</a><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                <i class="fas fa-adjust fa-fw"></i>
            </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
                <div class="container"><div class="toc" id="toc-auto">
            <h2 class="toc-title">目录</h2>
            <div class="toc-content" id="toc-content-auto"></div>
        </div><article class="page single"><h1 class="single-title animated flipInX">09-面向对象编程语言</h1><div class="post-meta">
            <div class="post-meta-line"><span class="post-author"><a href="https://adbean.gitee.io/" title="Author" target="_blank" rel="noopener noreffer author" class="author"><i class="fas fa-user-circle fa-fw"></i>Adbean</a></span>&nbsp;<span class="post-category">收录于 <a href="../../categories/%E4%BD%9C%E4%B8%9A/"><i class="far fa-folder fa-fw"></i>作业</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2020-10-24">2020-10-24</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;约 528 字&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;预计阅读 2 分钟&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>目录</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents">
  <ul>
    <li><a href="#类和对象">类和对象</a>
      <ul>
        <li><a href="#类">类</a></li>
        <li><a href="#对象">对象</a></li>
        <li><a href="#区别">区别</a></li>
        <li><a href="#属性和方法">属性和方法</a></li>
        <li><a href="#与其他对象沟通">与其他对象沟通</a></li>
        <li><a href="#类的命名">类的命名</a></li>
      </ul>
    </li>
  </ul>
</nav></div>
            </div><div class="content" id="content"><h2 id="类和对象">类和对象</h2>
<p>根据后面的素材，识别类和对象。</p>
<p>阅读“<a href="http://www.7k7k.com/swf/10718.htm" target="_blank" rel="noopener noreffer">牧师与恶魔过河</a>”的游戏介绍并玩游
戏。然后回答问题</p>
<p><img
        class="lazyload"
        src="../../svg/loading.min.svg"
        data-src="../../finished.png"
        data-srcset="../../finished.png, ../../finished.png 1.5x, ../../finished.png 2x"
        data-sizes="auto"
        alt="/finished.png"
        title="game" /></p>
<ul>
<li>游戏涉及哪些<strong>类</strong>。请<strong>列表</strong>说明</li>
<li>游戏中有哪些<strong>对象</strong>，各几个。例如，船（一个）</li>
<li>类和对象的<strong>区别</strong>是什么？举一个例子说明</li>
<li>游戏中的魔鬼，有哪些<strong>属性和方法</strong>？</li>
<li>假设魔鬼被鼠标点中，会执行 <strong>onclick</strong> 事件，请用<strong>文字（伪代码）<strong>描述这个事件中魔鬼</strong>与其他对象沟通</strong>的过程。</li>
<li><strong>类或对象</strong>会是动词吗？</li>
</ul>
<h3 id="类">类</h3>
<table>
<thead>
<tr>
<th align="center">类名</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">人类</td>
</tr>
<tr>
<td align="center">牧师</td>
</tr>
<tr>
<td align="center">恶魔</td>
</tr>
<tr>
<td align="center">船</td>
</tr>
<tr>
<td align="center">岸</td>
</tr>
<tr>
<td align="center">消息</td>
</tr>
<tr>
<td align="center">计时器</td>
</tr>
<tr>
<td align="center">按钮</td>
</tr>
<tr>
<td align="center">启动</td>
</tr>
<tr>
<td align="center">背景</td>
</tr>
<tr>
<td align="center">河</td>
</tr>
</tbody>
</table>
<h3 id="对象">对象</h3>
<ul>
<li>船(1)</li>
<li>恶魔(3)</li>
<li>牧师(3)</li>
<li>计时器(1)</li>
<li>岸(2)</li>
<li>河(1)</li>
<li>按钮(3)</li>
<li>背景(1)</li>
</ul>
<h3 id="区别">区别</h3>
<p><strong>类</strong>是一类事物的<strong>模板</strong>，描述一类对象的行为和状态</p>
<p><strong>对象</strong>是类的一个<strong>实例</strong>，具有该类的状态和行为</p>
<blockquote>
<p>例如：<strong>学生</strong>是一个<strong>类</strong>，而<strong>小明</strong>则是一个对象，属于学生类</p>
<p>对于该游戏，可以认为牧师和恶魔都具有一样的行为与状态，例如可以点击上船等等，可以认为牧师和恶魔都是继承了人的<strong>类</strong>，而牧师和恶魔是<strong>子类</strong>。</p>
</blockquote>
<h3 id="属性和方法">属性和方法</h3>
<p>游戏中的魔鬼应该具有如下<strong>属性和方法</strong>：</p>
<p><strong>属性</strong>：</p>
<ul>
<li>名字</li>
<li>位置</li>
<li>是否在船上</li>
</ul>
<p><strong>方法</strong>：</p>
<ul>
<li>上船</li>
<li>上岸</li>
<li>刺杀牧师</li>
</ul>
<h3 id="与其他对象沟通">与其他对象沟通</h3>
<pre><code class="language-Pseudocode" data-lang="Pseudocode">IF (the devil is on clicked) THEN
  IF (the devil is on the shore) THEN
    move the devil onto the boat

  ELSE IF (the devil is on the boat) THEN
    move the devil onto the shore
</code></pre><h3 id="类的命名">类的命名</h3>
<p>类的命名最好遵循<strong>规范</strong>，类名用<strong>名词</strong>、<strong>代词</strong>或<strong>动名词</strong>，最好不要用动词。</p>
<p>而类的<strong>属性</strong>也是如此，最好使用<strong>名词</strong>，或是<strong>形容词</strong></p>
<p>类的<strong>方法</strong>就可以使用<strong>动词</strong>命名</p>
</div><div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>更新于 2020-10-24</span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"></div>
            <div class="post-info-share">
                <span></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"><i class="fas fa-tags fa-fw"></i>&nbsp;<a href="../../tags/%E4%BD%9C%E4%B8%9A/">作业</a>,&nbsp;<a href="../../tags/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/">面向对象</a></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">返回</a></span>&nbsp;|&nbsp;<span><a href="../../">主页</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="../../posts/my-fourth-project/" class="prev" rel="prev" title="04-硬件编程--机器指令编程"><i class="fas fa-angle-left fa-fw"></i>04-硬件编程--机器指令编程</a>
            <a href="../../posts/my-tenth-post/" class="next" rel="next" title="10-数据结构与算法设计">10-数据结构与算法设计<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
</article></div>
            </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">由 <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.74.3">Hugo</a> 强力驱动 | 主题 - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw"></i> LoveIt</a>
                </div><div class="footer-line"><i class="far fa-copyright fa-fw"></i><span itemprop="copyrightYear">2020 - 2021</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="https://adbean.gitee.io/" target="_blank">Adbean</a></span>&nbsp;|&nbsp;<span class="license"><a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a></span></div>
        </div>
    </footer></div>

        <div id="fixed-buttons"><a href="#" id="back-to-top" class="fixed-button" title="回到顶部">
                <i class="fas fa-arrow-up fa-fw"></i>
            </a><a href="#" id="view-comments" class="fixed-button" title="查看评论">
                <i class="fas fa-comment fa-fw"></i>
            </a>
        </div><link rel="stylesheet" href="../../lib/katex/katex.min.css"><link rel="stylesheet" href="../../lib/katex/copy-tex.min.css"><script type="text/javascript" src="../../lib/smooth-scroll/smooth-scroll.min.js"></script><script type="text/javascript" src="../../lib/lazysizes/lazysizes.min.js"></script><script type="text/javascript" src="../../lib/clipboard/clipboard.min.js"></script><script type="text/javascript" src="../../lib/katex/katex.min.js"></script><script type="text/javascript" src="../../lib/katex/auto-render.min.js"></script><script type="text/javascript" src="../../lib/katex/copy-tex.min.js"></script><script type="text/javascript" src="../../lib/katex/mhchem.min.js"></script><script type="text/javascript">window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":50},"comment":{},"math":{"delimiters":[{"display":true,"left":"$$","right":"$$"},{"display":true,"left":"\\[","right":"\\]"},{"display":false,"left":"$","right":"$"},{"display":false,"left":"\\(","right":"\\)"}],"strict":false}};</script><script type="text/javascript" src="../../js/theme.min.js"></script></body>
</html>
